package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.RechargeItem;
import cn.wolfcode.crm.query.JSONResult;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.query.RechargeItemQueryObject;
import cn.wolfcode.crm.service.IRechargeItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("rechargeItem")
public class RechargeItemController {

    @Autowired
    private IRechargeItemService rechargeItemService;

    //由于dataGrid组件返回必须为json,所以跳转界面就分开
    @RequestMapping("view")
    public String view(){
        return "recharge";
    }


    //页面数据
    @RequestMapping("query")
    @ResponseBody
    public PageResult query(RechargeItemQueryObject qo){
        return rechargeItemService.query(qo);
    }


    //充值业务
    @RequestMapping("recharge")
    @ResponseBody
    public JSONResult recharge(RechargeItem rechargeItem){
        JSONResult result = new JSONResult();
        try{
            rechargeItemService.recharge(rechargeItem);
        }catch (Exception e){
            e.printStackTrace();
            result.mark(e.getMessage());
        }
        return result;
    }


}
